<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>新浪下拉菜单</title>
    <style>
        li {list-style: none;}
       
        ul.nav>li {
                float: left;
                width: 50px;
                
        }
        ul.nav ul {
            display: none;
        }
    </style>
</head>

<body>
    <div id="root">
        <ul class="nav" >
            <li style="background-color: green;">
                <a href="">微博</a>
                <ul>
                    <li><a href="">1</a></li>
                    <li><a href="">2</a></li>
                    <li><a href="">3</a></li>
                </ul>
            </li>
            <li style="background-color: yellowgreen;"><a href="">博客</a>
                <ul>
                    <li><a href="">1</a></li>
                    <li><a href="">2</a></li>
                    <li><a href="">3</a></li>
                </ul>
            </li>
            <li style="background-color: palegoldenrod;"><a href="">新闻</a>
                <ul>
                    <li><a href="">1</a></li>
                    <li><a href="">2</a></li>
                    <li><a href="">3</a></li>
                </ul>
            </li>
        </ul>
    </div>
</body>
<script>
    let as=document.getElementsByTagName('a')
    for(let a of as) {a.href='#'}
   let nav= document.querySelector('ul.nav')
   
   let lis=nav.children
  for(let li of lis){
    let ul=li.children[1]
   ul.style.display='none'
   
    li.onmouseover=function (){
        // console.log( a.parentNode.children[1])
        li.children[1].style.display='block'
    }
    li.onmouseout=function (){
        li.children[1].style.display='none'
    }
  }
</script>

</html>